/**
 * @Title: integrityArtificialScore_service.js
 * @Description: TODO
 * Copyright: Copyright (c) 2015
 * Company:中国平安
 *
 * @Project mhis-fwa-131
 * @author EX-LILIUZHU001
 * @date 2015年1月29日 上午11:46:26
 * @version V1.0
 */
;
(function(){
	'use strict';
	var app = angular.module('fwa.services');
	app.service('IntegrityArtificialScoreService',['$http','BaseURL', function($http, baseUrl){
		var debug = false,
		serv = this,		
			urls = {
				getIntegrityArtificialDoctor:baseUrl + 'integrityMedicalDesc/integrityDoctor.do',
				saveIntegrityArtificialDoctor:baseUrl + 'integrityMedicalDesc/saveIntegrityDoctor.do',
				backIntegrityDoctorProcess:baseUrl + 'integrityMedicalDesc/backIntegrityDoctorProcess.do',
				integrityArtificialScoreInfo:baseUrl + 'integrityMedicalDesc/integrityArtificialScoreInfo.do',
				batchArtificialScore:baseUrl + 'integrityMedicalDesc/batchArtificialScore.do'				
		};
		serv.systemIntegritys = [];
		serv.ownerIntegritys = [];
		serv.systemIntegrityMarks = [];
		serv.ownerIntegrityMarks = [];
		serv.startDate = null;
		serv.endDate = null;
		serv.doctorCode = null;
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		};
		serv.getIntegrityArtificialDoctor = function(params) {
			return $http.post(getUrl('getIntegrityArtificialDoctor'),params);			
		}
		//保存
		serv.saveIntegrityArtificialDoctor = function(params) {
			return $http.post(getUrl('saveIntegrityArtificialDoctor'),params);			
		}
		//登记批量提交
		serv.batchArtificialScore = function(params) {
			return $http.post(getUrl('batchArtificialScore'),params);			
		}		
		/**
		 * 撤回
		 */
		serv.backIntegrityDoctorProcess = function(params) {
			return $http({
				url:getUrl('backIntegrityDoctorProcess'),
				method:'GET',
				params:params
			});
		}
		/**
		 * 查询暂存信息
		 */
		serv.integrityArtificialScoreInfo = function(params) {
			return $http({
				url:getUrl('integrityArtificialScoreInfo'),
				method:'GET',
				params:params
			});
		}		
		serv.getIntegrityMedicalDesc = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalDesc'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityMedicalMark = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalMark'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityExport = function(params) {
			return $http({
				url:getUrl('getIntegrityExport'),
				method:'GET',
				params:params
			});
		}
		serv.getIntegrityMedicalTotal = function(params) {
			return $http({
				url:getUrl('getIntegrityMedicalTotal'),
				method:'GET',
				params:params
			});
		}
		//医生列表
		serv.getIntegrityDoctor = function(params) {
			return $http({
				url:getUrl('getIntegrityDoctor'),
				method:'GET',
				params:params
			});
		}
		//机构列表
		serv.getIntegrityOrg = function(params) {
			return $http({
				url:getUrl('getIntegrityOrg'),
				method:'GET',
				params:params
			});
		}
		/**医疗机构**/
        serv.initMedicalOrgInfoList = function(){
			if(!serv.medicalOrgInfoList){
				$http({
			    	 method: "get",
			    	 url:baseUrl+'community/getNewMedicalOrgInfoList.do'
				}).success(function(response, status, headers, config){
					serv.medicalOrgInfoList = response.medicalOrgList;
				});
			}
		}
        
		//人工录入扣分
	     serv.saveIntegrityPoints = function (params){
	    	 return $http.post(getUrl('saveIntegrityPoints'),params);
	     }
		/**获得开始时间*/
		serv.getStartDate= function(){
			var date = new Date();
			date.setMonth(date.getMonth());
			var year1 = date.getFullYear()-1;
			var month1 = date.getMonth();
			if(month1 < 12){
				month1 += 1;
			}else{
				year1 += 1;
				month1 = 1;
			}
			var d = date.getDate();
			month1 = month1 < 10 ? ("0" + month1) : month1;
			var startDate = year1 + "-" + month1 + '-' +d;
			return startDate;
		}
		/**获得结束时间*/
		serv.getEndDate= function(){
			var date = new Date();
			date.setMonth(date.getMonth());
			var year1 = date.getFullYear();
			var month1 = date.getMonth()+1;
			var d = date.getDate();
			month1 = month1 < 10 ? ("0" + month1) : month1;
			var startDate = year1 + "-" + month1 + '-' +d;
			return startDate;
		}
		
	}]);
	
})();